<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
  //如果是嵌套set, 并且传递了receiver, 那么被嵌套的那个的set的receiver就是我们传递的那个

  let obj = {}
  let proto = { a: 1 }
  let proxyProto = new Proxy(proto, {
    get(target, key, receiver) {
      return Reflect.get(target, key, receiver)
    },
    set(target, key, value, receiver) {
      console.log('proxyProto, receiver == myProxy:',proxyProto, receiver === myProxy); //proxyProto, receiver == myProxy: Proxy {a: 1} true
      return Reflect.set(target, key, value, receiver)// 不要考虑原型链的set
    }
  })
  Object.setPrototypeOf(obj, proxyProto)
  let myProxy = new Proxy(obj, {  // proxy(obj)
    get(target, key, receiver) {
      return Reflect.get(target, key, receiver)
    },
    set(target, key, value, receiver) {
      console.log(receiver === myProxy); //true
      return Reflect.set(target, key, value, receiver) // 调用reflect.set 会触发原型链的set
    }
  })
  myProxy.a = 100 // 内部的特点
</script>
</body>
</html>
